Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(//core/converters): Add normalization plugin #323

Closed
wants to merge 2 commits into from
Closed

Conversation

peri044
Copy link
Collaborator

@peri044 peri044 commented Feb 5, 2021

Description

Add normalization plugin. This plugin currently uses pytorch aten library kernels.

Fixes #280

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes

@peri044 peri044 requested a review from narendasan February 5, 2021 05:53
@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: tests Issues re: Tests labels Feb 5, 2021
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to C++ style guidelines:

diff --git a/workspace/tests/core/conversion/converters/test_element_wise.cpp b/tmp/changes.txt
index 4b2fe9c..5431e9a 100644
--- a/workspace/tests/core/conversion/converters/test_element_wise.cpp
+++ b/tmp/changes.txt
@@ -172,117 +172,117 @@ TEST(Converters, ATenNeScalarConvertsCorrectly) {
  pointwise_test_helper(graph, true, false, {3, 4, 2});
  ;

-TEST(Converters, ATenClampMinConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenClampMinConvertsCorrectly) {
+    const auto graph = R"IR(
    graph(%x.1 : Tensor):
            %2 : int = prim::Constant[value=-2]()
            %3 : None = prim::Constant()
            %4 : Tensor = aten::clamp(%x.1, %2, %3)
            return (%4))IR";
-  pointwise_test_helper(graph, true);
-}
+    pointwise_test_helper(graph, true);
+  }

-TEST(Converters, ATenClampMaxConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenClampMaxConvertsCorrectly) {
+    const auto graph = R"IR(
    graph(%x.1 : Tensor):
            %2 : int = prim::Constant[value=3]()
            %3 : None = prim::Constant()
            %4 : Tensor = aten::clamp(%x.1, %3, %2)
            return (%4))IR";
-  pointwise_test_helper(graph, true);
-}
+    pointwise_test_helper(graph, true);
+  }

-TEST(Converters, ATenClampMinMaxConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenClampMinMaxConvertsCorrectly) {
+    const auto graph = R"IR(
    graph(%x.1 : Tensor):
            %2 : int = prim::Constant[value=3]()
            %3 : int = prim::Constant[value=-2]()
            %4 : Tensor = aten::clamp(%x.1, %3, %2)
            return (%4))IR";
-  pointwise_test_helper(graph, true);
-}
+    pointwise_test_helper(graph, true);
+  }

-TEST(Converters, ATenGreaterThanConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenGreaterThanConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor, %1 : Tensor):
        %2 : Tensor = aten::gt(%0, %1)
        return (%2))IR";
-  pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
-}
+    pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
+  }

-TEST(Converters, ATenGreaterThanScalarConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenGreaterThanScalarConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor):
        %scalar : float = prim::Constant[value=3]()
        %2 : Tensor = aten::gt(%0, %scalar)
        return (%2))IR";
-  pointwise_test_helper(graph, true, false, {5, 5});
-}
+    pointwise_test_helper(graph, true, false, {5, 5});
+  }

-TEST(Converters, ATenLessThanConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenLessThanConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor, %1 : Tensor):
        %2 : Tensor = aten::lt(%0, %1)
        return (%2))IR";
-  pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
-}
+    pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
+  }

-TEST(Converters, ATenLessThanScalarConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenLessThanScalarConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor):
        %scalar : float = prim::Constant[value=3]()
        %2 : Tensor = aten::lt(%0, %scalar)
        return (%2))IR";
-  pointwise_test_helper(graph, true, false, {5, 5});
-}
+    pointwise_test_helper(graph, true, false, {5, 5});
+  }

-TEST(Converters, ATenEqualConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenEqualConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor, %1 : Tensor):
        %2 : Tensor = aten::eq(%0, %1)
        return (%2))IR";
-  pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
-}
+    pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
+  }

-TEST(Converters, ATenEqualScalarConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenEqualScalarConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor):
        %scalar : float = prim::Constant[value=3]()
        %2 : Tensor = aten::eq(%0, %scalar)
        return (%2))IR";
-  pointwise_test_helper(graph, true, false, {5, 5});
-}
+    pointwise_test_helper(graph, true, false, {5, 5});
+  }

-TEST(Converters, ATenGEConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenGEConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor, %1 : Tensor):
        %2 : Tensor = aten::ge(%0, %1)
        return (%2))IR";
-  pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
-}
+    pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
+  }

-TEST(Converters, ATenGEScalarConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenGEScalarConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor):
        %scalar : float = prim::Constant[value=3]()
        %2 : Tensor = aten::ge(%0, %scalar)
        return (%2))IR";
-  pointwise_test_helper(graph, true, false, {5, 5});
-}
+    pointwise_test_helper(graph, true, false, {5, 5});
+  }

-TEST(Converters, ATenLEConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenLEConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor, %1 : Tensor):
        %2 : Tensor = aten::le(%0, %1)
        return (%2))IR";
-  pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
-}
+    pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
+  }

-TEST(Converters, ATenLEScalarConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenLEScalarConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor):
        %scalar : float = prim::Constant[value=3]()
        %2 : Tensor = aten::le(%0, %scalar)
        return (%2))IR";
-  pointwise_test_helper(graph, true, false, {5, 5});
-}
+    pointwise_test_helper(graph, true, false, {5, 5});
+  }
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to C++ style guidelines:

diff --git a/workspace/tests/core/conversion/converters/test_element_wise.cpp b/tmp/changes.txt
index 4b2fe9c..5431e9a 100644
--- a/workspace/tests/core/conversion/converters/test_element_wise.cpp
+++ b/tmp/changes.txt
@@ -172,117 +172,117 @@ TEST(Converters, ATenNeScalarConvertsCorrectly) {
  pointwise_test_helper(graph, true, false, {3, 4, 2});
  ;

-TEST(Converters, ATenClampMinConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenClampMinConvertsCorrectly) {
+    const auto graph = R"IR(
    graph(%x.1 : Tensor):
            %2 : int = prim::Constant[value=-2]()
            %3 : None = prim::Constant()
            %4 : Tensor = aten::clamp(%x.1, %2, %3)
            return (%4))IR";
-  pointwise_test_helper(graph, true);
-}
+    pointwise_test_helper(graph, true);
+  }

-TEST(Converters, ATenClampMaxConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenClampMaxConvertsCorrectly) {
+    const auto graph = R"IR(
    graph(%x.1 : Tensor):
            %2 : int = prim::Constant[value=3]()
            %3 : None = prim::Constant()
            %4 : Tensor = aten::clamp(%x.1, %3, %2)
            return (%4))IR";
-  pointwise_test_helper(graph, true);
-}
+    pointwise_test_helper(graph, true);
+  }

-TEST(Converters, ATenClampMinMaxConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenClampMinMaxConvertsCorrectly) {
+    const auto graph = R"IR(
    graph(%x.1 : Tensor):
            %2 : int = prim::Constant[value=3]()
            %3 : int = prim::Constant[value=-2]()
            %4 : Tensor = aten::clamp(%x.1, %3, %2)
            return (%4))IR";
-  pointwise_test_helper(graph, true);
-}
+    pointwise_test_helper(graph, true);
+  }

-TEST(Converters, ATenGreaterThanConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenGreaterThanConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor, %1 : Tensor):
        %2 : Tensor = aten::gt(%0, %1)
        return (%2))IR";
-  pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
-}
+    pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
+  }

-TEST(Converters, ATenGreaterThanScalarConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenGreaterThanScalarConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor):
        %scalar : float = prim::Constant[value=3]()
        %2 : Tensor = aten::gt(%0, %scalar)
        return (%2))IR";
-  pointwise_test_helper(graph, true, false, {5, 5});
-}
+    pointwise_test_helper(graph, true, false, {5, 5});
+  }

-TEST(Converters, ATenLessThanConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenLessThanConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor, %1 : Tensor):
        %2 : Tensor = aten::lt(%0, %1)
        return (%2))IR";
-  pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
-}
+    pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
+  }

-TEST(Converters, ATenLessThanScalarConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenLessThanScalarConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor):
        %scalar : float = prim::Constant[value=3]()
        %2 : Tensor = aten::lt(%0, %scalar)
        return (%2))IR";
-  pointwise_test_helper(graph, true, false, {5, 5});
-}
+    pointwise_test_helper(graph, true, false, {5, 5});
+  }

-TEST(Converters, ATenEqualConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenEqualConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor, %1 : Tensor):
        %2 : Tensor = aten::eq(%0, %1)
        return (%2))IR";
-  pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
-}
+    pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
+  }

-TEST(Converters, ATenEqualScalarConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenEqualScalarConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor):
        %scalar : float = prim::Constant[value=3]()
        %2 : Tensor = aten::eq(%0, %scalar)
        return (%2))IR";
-  pointwise_test_helper(graph, true, false, {5, 5});
-}
+    pointwise_test_helper(graph, true, false, {5, 5});
+  }

-TEST(Converters, ATenGEConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenGEConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor, %1 : Tensor):
        %2 : Tensor = aten::ge(%0, %1)
        return (%2))IR";
-  pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
-}
+    pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
+  }

-TEST(Converters, ATenGEScalarConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenGEScalarConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor):
        %scalar : float = prim::Constant[value=3]()
        %2 : Tensor = aten::ge(%0, %scalar)
        return (%2))IR";
-  pointwise_test_helper(graph, true, false, {5, 5});
-}
+    pointwise_test_helper(graph, true, false, {5, 5});
+  }

-TEST(Converters, ATenLEConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenLEConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor, %1 : Tensor):
        %2 : Tensor = aten::le(%0, %1)
        return (%2))IR";
-  pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
-}
+    pointwise_test_helper(graph, false, false, {5, 5}, {5, 5});
+  }

-TEST(Converters, ATenLEScalarConvertsCorrectly) {
-  const auto graph = R"IR(
+  TEST(Converters, ATenLEScalarConvertsCorrectly) {
+    const auto graph = R"IR(
      graph(%0 : Tensor):
        %scalar : float = prim::Constant[value=3]()
        %2 : Tensor = aten::le(%0, %scalar)
        return (%2))IR";
-  pointwise_test_helper(graph, true, false, {5, 5});
-}
+    pointwise_test_helper(graph, true, false, {5, 5});
+  }
ERROR: Some files do not conform to style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code conforms to Python style guidelines

@narendasan narendasan added the on hold PR is on hold pending another PR or feature being implemented label Mar 19, 2021
@narendasan
Copy link
Collaborator

handled in #425

@narendasan narendasan closed this Apr 30, 2021
@peri044 peri044 deleted the norm branch November 16, 2021 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: tests Issues re: Tests on hold PR is on hold pending another PR or feature being implemented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

↔ [Converter] Add support for aten::norm in TRTorch
2 participants